# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=py3-poetry-core
_pkgname=poetry-core
pkgver=1.0.8
pkgrel=1
pkgdesc="PEP 517 build backend implementation for Poetry"
url="https://github.com/python-poetry/poetry-core"
arch="noarch"
license="MIT"
depends="python3 py3-jsonschema py3-lark-parser py3-six py3-tomlkit"
makedepends="py3-build py3-installer"
checkdepends="py3-pytest py3-pytest-mock py3-virtualenv python3-dev py3-setuptools py3-pip"
source="$_pkgname-$pkgver.tar.gz::https://github.com/python-poetry/poetry-core/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

check() {
	# skip test that is incompatible with the .gitignore file in the aports tree (src entry)
	pytest tests \
		--deselect tests/masonry/builders/test_sdist.py::test_includes_with_inline_table
	PYTHONPATH="$PWD" pytest --integration tests/integration
}

build() {
	# poetry-core excludes files specified in .gitignore
	# fixed by setting GIT_DIR away from the aports tree's top-level directory
	GIT_DIR="$PWD" python3 -m build --no-isolation --skip-dependency-check --wheel
}

package() {
	python3 -m installer -d "$pkgdir" \
		dist/poetry_core-$pkgver-py2.py3-none-any.whl

	# remove vendored versions of installed modules
	local sitedir=$(python3 -c "import site; print(site.getsitepackages()[0])")
	rm -r "$pkgdir/$sitedir"/poetry/core/_vendor

	install -Dm644 poetry/core/json/schemas/poetry-schema.json \
		"$pkgdir/$sitedir"/poetry/core/json/schemas/poetry-schema.json
	install -Dm644 poetry/core/spdx/data/licenses.json \
		"$pkgdir/$sitedir"/poetry/core/spdx/data/licenses.json
}

sha512sums="
6dfed1e1124c37a5f0ec535ede8848e25466da3df6fa6629f6330ce32f05a4d82725d64407e5bcf294d6e467b52966642505ee29f563d3794c4e7aca78045285  poetry-core-1.0.8.tar.gz
"
